package pojo;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 租车记录实体类
 */
public class Record implements Serializable {

    /**
     *记录编号
     */
    private int id;

    /**
     * 借车人
     */
    private User user;
    /**
     * 车辆
     */
    private Car car;
    /**
     * 租车时间
     */
    private Date rentTime;
    //租车时间的字符串形式
    private String rentStr="";
    /**
     * 还车时间
     */
    private Date backTime;
    //租车时间的字符串形式  默认为"未归还"
    private String backStr="未归还";
    private SimpleDateFormat s=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    //借还车相差天使 默认为0
    private int day=0;
    public Record() {
    }

    public Record(int id, User user, Car car) {
        this.id = id;
        this.user = user;
        this.car = car;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public Car getCar() {
        return car;
    }

    public void setCar(Car car) {
        this.car = car;
    }

    public Date getRentTime() {
        return rentTime;
    }

    public void setRentTime(Date rentTime) {
        rentStr=s.format(rentTime);
        this.rentTime = rentTime;
    }

    public Date getBackTime() {
        return backTime;
    }

    public void setBackTime(Date backTime) {
        backStr=s.format(backTime);
        this.backTime = backTime;
    }

    public int getDay() {
        return day;
    }

    public void setDay(int day) {
        this.day = day;
    }

    public String rentShow() {
        return car.getId()+"\t"+car.getName()+"\t"+car.getPrice()+"\t"+car.getRemark()+"\t"+car.getBrand()+"\t"+car.getType()+"\t"+rentStr;
    }
    public  String backShow(){
        return car.getId()+"\t"+car.getName()+"\t"+car.getPrice()+"\t"+car.getPrice()*day+"\t"+car.getRemark()+"\t"+car.getBrand()+"\t"+car.getType()+"\t"+rentStr+"\t"+backStr;
    }
    public  String record(){
        return id+"\t\t"+car.getId()+"\t\t"+car.getName()+"\t\t"+car.getPrice()*day+"\t\t"+car.getRemark()+"\t\t"+car.getBrand()+"\t\t"+car.getType()+"\t\t"+rentStr+"\t\t"+backStr;
    }

    public String adminRecord() {
        return id+"\t\t"+car.getId()+"\t\t"+car.getName()+"\t\t"+user.getName()+"\t\t"+car.getPrice()*day+"\t\t"+car.getRemark()+"\t\t"+car.getBrand()+"\t\t"+car.getType()+"\t\t"+rentStr+"\t\t"+backStr;

    }
}
